import { defineStore } from "pinia";
import { KeepAliveState } from "../interface";
export const useKeepAliveStore = defineStore({
  id: "keepAlive",
  state: (): KeepAliveState => ({
    keepAliveName: []
  }),
  getters: {},
  actions: {
    /**
     * @desc: Set KeepAliveName
     * @param { string[] } keepAliveName
     */
    setKeepAliveName(keepAliveName: string[] = []) {
      this.keepAliveName = keepAliveName;
    },
    /**
     * @desc:  Add KeepAliveName
     * @param { string } name
     */
    addKeepAliveName(name: string) {
      !this.keepAliveName.includes(name) && this.keepAliveName.push(name);
    },
    /**
     * @desc:  Remove KeepAliveName
     * @param { string } name
     */
    removeKeepAliveName(name: string) {
      this.keepAliveName = this.keepAliveName.filter(item => item !== name);
    }
  }
});
